#pragma once
#include <windows.h>

#define LOG_DEBUG(format,...) do { \
		char msg[MAX_PATH]; \
		sprintf_s(msg,MAX_PATH,format,__VA_ARGS__); \
		OutputDebugStringA(msg);  \
	}while(0)

#define LOG_DEBUGW(format,...) do { \
		WCHAR msg[MAX_PATH]; \
		swprintf_s(msg,MAX_PATH,format,__VA_ARGS__); \
		OutputDebugStringW(msg);  \
	}while(0)

#define MSG_COPYDATA                  0xffff
#define MSG_EXIT                      0xfffe

#define MSG_TEST                    0x2000

#define MSG_INIT                    0x1000
#define MSG_BASEINFO             0x1001
#define MSG_GETCROSSPROCESSTHREADID 0x1002
#define MSG_HOOKSETMONSTERGBLOOD    0x1003
#define MSG_DLLEXIT                 0x1004
#define MSG_CLOSEMAPPING            0x1005
#define MSG_HOOKDECRYPT             0x1006
#define MSG_HOOKSETBLOOD            0x1007
#define MSG_STARTKILLTHREAD         0x1008
#define MSG_STOPKILLTHREAD          0x1009
#define MSG_MOTIFYTHREADID          0x1010
#define MSG_DISCONNECT              0x1011
#define MSG_HEARTBEAT               0x1012
#define MSG_THREESIDES              0x1013
#define MSG_SECURITYMODE            0x1014
#define MSG_FINISH                  0x1015
#define MSG_GOLD                    0x1016
#define MSG_RUNNING                   0x1017
#define PIPE_BUFSIZE  0x1000

typedef struct tagRequest{
	UINT   msg;
	DWORD  cbData;
}Request,*PRequest;

typedef struct tagResponse{
	DWORD  code;
	DWORD  cbData;
}Response,*PResponse;


typedef struct tagConsoleInfo{
	DWORD threadId[20];
	char  WorkDirectory[MAX_PATH];
}ConsoleInfo,*PConsoleInfo;

typedef struct tagManInfo{
	DWORD pid;
	HWND  hwnd;
	HWND  dnfhwnd;
	DWORD account;
	DWORD threadId;
	WCHAR name[MAX_PATH];
	DWORD level;
	DWORD gold;
	DWORD blood;
	DWORD maxBlood;
	DWORD magic;
	DWORD maxMagic;
	DWORD weight;
	DWORD maxWeight;
	DWORD fatigue;
	DWORD maxFatigue;
}ManInfo,*PManInfo;

#define NAKED __declspec(naked) 

typedef LONG  NTSTATUS; 
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)

#define STATUS_INFO_LENGTH_MISMATCH 0xC0000004

typedef struct tagMoveInfo{
	DWORD baseAddr;
	DWORD x;
	DWORD y;
	DWORD z;
}MoveInfo,*PMoveInfo;

typedef struct tagGate{
	DWORD baseAddr;
	DWORD count;
	BOOL  lordGate;
	DWORD direction;
	DWORD x;
	DWORD y;
	DWORD z;
}Gate,*PGate,**PPGate;

typedef struct tagMap{
	DWORD  mapId;
	PPGate gate;
	DWORD  gateNum;
	BOOL   incLordGate;
	BOOL   lordMap;
	BOOL   allGatePassed;
	BOOL   passed;
	BOOL   isCourseMap;
}Map,*PMap,**PPMap;



typedef struct tagPoint{
	int x;
	int y;
}Point,*PPoint;

#define MSG_IMAGE 0x0
#define MSG_TEXT  0x1
#define MSG_INT  0x2

typedef struct tagAMSG{
	DWORD type;
	DWORD srcAddr;
	DWORD destAddr;
	DWORD cbData;
}AMSG,*PAMSG;

typedef struct tagCityCoordinate{
	int regionId;
	int posId;
	int x;
	int y;
}CityCoordinate,*PCityCoordinate;

typedef struct tagWeaponInfo{
	DWORD index;
	DWORD baseAddr;
	DWORD phyAttack;
	BOOL  isSeal;
}WeaponInfo,*PWeaponInfo;


typedef struct tagShopInfo{
	DWORD level;
	DWORD shopIndex;
	DWORD itemIndex;
	DWORD price;
	DWORD phyAttack;
}ShopInfo,*PShopInfo;

typedef struct tagSkillInfo{
	DWORD level;
	DWORD x;
	DWORD y;
}SkillInfo,*PSkillInfo;

#define SOME_DATA_PATH "c:/some.data"

typedef struct tagSomeData{
	DWORD imeThreadId;
	DWORD dnfThreadId;
	char  path[MAX_PATH];
}SomeData,*PSomeData;